package flc.ast.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.os.Bundle;
import android.view.View;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.bean.IdPhotosBean;
import flc.ast.databinding.ActivityPhotoDetailBinding;
import flc.ast.utils.Content;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.utils.StkPermissionHelper;

public class PhotoDetailActivity extends BaseAc<ActivityPhotoDetailBinding> {

    private IdPhotosBean idPhotosBean;

    @Override
    protected int onCreate() {
        return R.layout.activity_photo_detail;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(this, mDataBinding.event1Container);

        mDataBinding.ivPhotoDetailBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.tvTakePhoto.setOnClickListener(this);
        mDataBinding.tvUploadPhoto.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()) {
            case R.id.tvTakePhoto://拍摄照片
                getPermission();
                break;
            case R.id.tvUploadPhoto://上传照片
                MyAlbumActivity.type = 0;
                startActivity(MyAlbumActivity.class);
                break;
        }
    }

    @Override
    protected void initData() {
        idPhotosBean = Content.sIdPhotosBean;
        mDataBinding.tvPhotoDetailTitle.setText(idPhotosBean.getName());
        mDataBinding.tvPhotoName.setText(idPhotosBean.getName());
        mDataBinding.tvPhotoMm.setText(idPhotosBean.getCyW() + "x" + idPhotosBean.getCyH() + getString(R.string.mm_text));
        mDataBinding.tvPhotoPx.setText(idPhotosBean.getPixelW() + "x" + idPhotosBean.getPixelH() + getString(R.string.px_text));
        mDataBinding.tvPhotoDpi.setText(idPhotosBean.getRes() + getString(R.string.dpi_text));
    }

    private void getPermission() {
        StkPermissionHelper.permission(Manifest.permission.CAMERA).reqPermissionDesc(getString(R.string.get_camera_permission)).callback(new StkPermissionHelper.ACallback() {
            @Override
            public void onGranted() {
                startActivity(CameraActivity.class);
            }
        }).request();
    }

}